package Controller;

import Service.impl.SnackOrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SnackSumPriceServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String numGet = request.getParameter("num");
        String priceGet = request.getParameter("price");
        if(numGet == null||numGet.equals("")){
            numGet="0";
        }
        if(priceGet == null||priceGet.equals("")){
            priceGet="0";
        }
        Integer num =Integer.parseInt(numGet);
        Integer price =Integer.parseInt(priceGet);
        SnackOrderServiceImpl snackOrderService=new SnackOrderServiceImpl();
        Integer sum=snackOrderService.SnackSumPrice(num,price);
        response.getWriter().print(sum);
    }
}
